<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>上传文件</title>
<script type="text/javascript">
$(document).ready(function(){
	function checkVail(){
		var fype = $('#upfile').val();
		fype=fype.toLowerCase();
		if(fype.lastIndexOf('.jpg')!=fype.length-4 && fype.lastIndexOf('.jpeg')!=fype.length-5){
			$('#msga').html('只能上传JPG格式的图片');
			return false;
		}
		if($.trim($('#fileDesc').val())==''){
			$('#msga').html('描述不能为空');
			return false;
		}
		$('#msga').html('');
		return true;
	}
	$('#toUploda').click(function(){
		if(checkVail()){
			$('#fileForm').vaildAjax(function(data){
				parent.addImg2LiAndCloseWind(data);
			});
		}
	});
	
});
</script>
</head>
<body>
<s:form action="system/UploadFile" id="fileForm" method="POST" enctype="multipart/form-data" onsubmit="return false;" >
	<table width="300" style="border: 1px solid silver ; " cellpadding="0" cellspacing="0" >
		<caption id="msga" style="color: red;"></caption>
		<tr>
			<td colspan="2" style="border-bottom: 1px solid silver;">选择文件：<s:file name="file" id="upfile" ></s:file></td>
		</tr>
		<tr>
			<td>文件描述：<s:textfield name="fileDesc" id="fileDesc"></s:textfield></td>
			<td width="50"><button id="toUploda">上传</button></td>
		</tr>
	</table>
</s:form>
</body>
</html>